#include "stringhandle.h"
namespace Moonlite {
namespace Data {
namespace Mpq {
	LPCSTR TStringHandle::Value::get()
	{
		if (_disposed)
		{
			throw gcnew System::ObjectDisposedException(nullptr);
		}

		return _value;
	}

	void TStringHandle::Cleanup(bool managed)
	{
		if (managed)
		{
			delete context;
		}

		_value = NULL;
		_disposed = true;
	}

	TStringHandle::TStringHandle(System::String^ value)
	{
		context = gcnew msclr::interop::marshal_context();
		_value = context->marshal_as<LPCSTR>(value);
	}

	TStringHandle::~TStringHandle()
	{
		Cleanup(true);
	}

	TStringHandle::!TStringHandle()
	{
		Cleanup(false);
	}
}
}
}